package com.briup.web.listener;

import com.briup.bean.BrowsingHistory;
import com.briup.bean.Shop;
import com.briup.bean.vo.CategoryVO;
import com.briup.service.IBrowsingHistoryService;
import com.briup.service.ICategoryService;
import com.briup.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;
@Component
public class ApplicationListener implements ServletContextListener {
    @Autowired
    private IShopService shopService;
    @Autowired
    private ICategoryService categoryService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext application = sce.getServletContext();
        //获取非特价商品
        List<Shop> AllShops = shopService.findAllShops();
        List<Shop> discountList = shopService.findDiscount();
        List<CategoryVO> categoryVOList = categoryService.findAllCategory();
        application.setAttribute("shops",AllShops);
        application.setAttribute("discountList",discountList);
        application.setAttribute("categories",categoryVOList);
    }
}
